home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
gtlayout-source.lha
/
LTP_DrawBox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-25
|
3KB
|
147 lines
/* GadTools layout toolkit
**
** Copyright © 1993-1995 by Olaf `Olsen' Barthel
** Freely distributable.
*/
#include "gtlayout_global.h"
VOID __regargs
LTP_DrawMultiLineButton(struct RastPort *RPort,WORD Left,WORD Top,WORD Width,WORD Height,struct ImageInfo *ImageInfo)
{
WORD Len,ThisTop,ThisLeft;
STRPTR *Lines = ImageInfo -> Lines;
WORD LineCount = ImageInfo -> LineCount;
STRPTR KeyStroke = ImageInfo -> KeyStroke;
ThisTop = Top + (Height - LineCount * RPort -> TxHeight) / 2 + RPort -> TxBaseline;
do
{
Len = strlen(*Lines);
ThisLeft = Left + (Width - TextLength(RPort,*Lines,Len)) / 2;
Move(RPort,ThisLeft,ThisTop);
Text(RPort,*Lines,Len);
if(KeyStroke)
{
if(KeyStroke >= *Lines && KeyStroke < *Lines + Len)
{
ULONG OldStyle;
if(KeyStroke != *Lines)
ThisLeft += TextLength(RPort,*Lines,(ULONG)KeyStroke - (ULONG)(*Lines));
OldStyle = SetSoftStyle(RPort,FSF_UNDERLINED,AskSoftStyle(RPort));
Move(RPort,ThisLeft,ThisTop);
Text(RPort,KeyStroke,1);
SetSoftStyle(RPort,OldStyle & ~FSF_UNDERLINED,OldStyle);
KeyStroke = NULL;
}
}
ThisTop += RPort -> TxHeight;
Lines++;
}
while(--LineCount);
}
VOID __regargs
LTP_DrawBox(struct RastPort *rp,struct DrawInfo *drawInfo,LONG left,LONG top,LONG width,LONG height,BOOLEAN selected,BOOLEAN ghosted,ImageInfo *imageInfo)
{
UWORD *pens = drawInfo -> dri_Pens;
UWORD pen1,pen2,pen3,pen4;
ImageTypes imageType = imageInfo -> ImageType;
if(selected)
{
pen1 = SHADOWPEN;
pen2 = SHINEPEN;
pen3 = FILLPEN;
pen4 = FILLTEXTPEN;
}
else
{
pen1 = SHINEPEN;
pen2 = SHADOWPEN;
pen3 = BACKGROUNDPEN;
pen4 = TEXTPEN;
}
LTP_SetPens(rp,pens[pen1],0,JAM1);
Move(rp,left + 1,top + 1);
Draw(rp,left + 1,top + height - 2);
Draw(rp,left,top + height - 1);
Draw(rp,left,top);
Draw(rp,left + width - 2,top);
LTP_SetAPen(rp,pens[pen2]);
Move(rp,left + width - 2,top + height - 2);
Draw(rp,left + width - 2,top + 1);
Draw(rp,left + width - 1,top);
Draw(rp,left + width - 1,top + height - 1);
Draw(rp,left + 1,top + height - 1);
LTP_SetAPen(rp,pens[pen3]);
RectFill(rp,left + 2,top + 1,left + 2 + width - 5,top + 1 + height - 3);
LTP_SetAPen(rp,pens[pen4]);
switch(imageType)
{
case IMAGECLASS_PICKER:
{
LONG Left = left + 4,
Top = top + 2,
Width = width - 8,
Height = height - 4;
LTP_DrawPicker(rp,FALSE,Left,Top,Width,Height);
break;
}
case IMAGECLASS_MULTILINEBUTTON:
LTP_DrawMultiLineButton(rp,left + 4,top + 2,width - 8,height - 4,imageInfo);
break;
case IMAGECLASS_LEFTINCREMENTER:
case IMAGECLASS_RIGHTINCREMENTER:
LTP_DrawIncrementer(rp,imageType == IMAGECLASS_LEFTINCREMENTER,left + 2,top + 1,width - 4,height - 2);
break;
#ifdef DO_TAPEDECK_KIND
case IMAGECLASS_BACKWARD:
case IMAGECLASS_FORWARD:
case IMAGECLASS_PREVIOUS:
case IMAGECLASS_NEXT:
case IMAGECLASS_RECORD:
case IMAGECLASS_PLAY:
case IMAGECLASS_STOP:
case IMAGECLASS_PAUSE:
case IMAGECLASS_EJECT:
case IMAGECLASS_REWIND:
LTP_DrawTapeButton(rp,imageInfo,left,top,width,height,drawInfo -> dri_Resolution . X,drawInfo -> dri_Resolution . Y,pens[pen3]);
break;
#endif /* DO_TAPEDECK_KIND */
}
if(ghosted)
{
if(width > 4 || height > 2)
{
LTP_SetAPen(rp,pens[BLOCKPEN]);
SetAfPt(rp,(UWORD *)&ghostingPat,1);
RectFill(rp,left + 2,top + 1,left + width - 1 - 2,top + height - 1 - 1);
SetAfPt(rp,NULL,0);
}
}
}